package inventory.stockManagement.view;

import java.awt.Color;
import java.awt.event.ActionListener;

import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;

import javax.swing.SpringLayout;
import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

import common.view.GinView;

import java.awt.Font;

public class OpenGinView extends JPanel
{
	private JTable table;
	private JList list;
	private GinView ginView;
	
	public OpenGinView() 
	{
		SpringLayout sl_this = new SpringLayout();
		this.setLayout(sl_this);
		
		JLabel lblOpenGins = new JLabel("Open Gins :");
		sl_this.putConstraint(SpringLayout.NORTH, lblOpenGins, 10, SpringLayout.NORTH,this);
		sl_this.putConstraint(SpringLayout.WEST, lblOpenGins, 10, SpringLayout.WEST, this);
		lblOpenGins.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		this.add(lblOpenGins);
		
		ginView = new GinView();
		sl_this.putConstraint(SpringLayout.NORTH, ginView, 33, SpringLayout.NORTH, this);
		sl_this.putConstraint(SpringLayout.WEST, ginView, 200, SpringLayout.WEST, this);
		sl_this.putConstraint(SpringLayout.SOUTH, ginView, -45, SpringLayout.SOUTH, this);
		sl_this.putConstraint(SpringLayout.EAST, ginView, -10, SpringLayout.EAST, this);
		this.add(ginView);
		
		
		
		
		list = new JList();
		sl_this.putConstraint(SpringLayout.NORTH, list, 6, SpringLayout.SOUTH, lblOpenGins);
		sl_this.putConstraint(SpringLayout.WEST, list, 10, SpringLayout.WEST, this);
		sl_this.putConstraint(SpringLayout.SOUTH, list, -45, SpringLayout.SOUTH, this);
		sl_this.putConstraint(SpringLayout.EAST, list, -10, SpringLayout.WEST,ginView);
		
		list.setBorder(new LineBorder(new Color(0, 0, 0)));
		list.setModel(new AbstractListModel() {
			String[] values = new String[] {"ITEM 1", "ITEM 2", "ITEM 3", "ITEM 4", "ITEM 5"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		
		this.add(list);
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	}
	

	public JTable getTable() {
		return table;
	}

	public void setTable(JTable table) {
		this.table = table;
	}


	public JList getList() {
		return list;
	}



	public void setList(JList list) {
		this.list = list;
	}


	public GinView getGinView() {
		return ginView;
	}


	public void setGinView(GinView ginView) {
		this.ginView = ginView;
	}

	public void addlistlistener(ListSelectionListener ls)
	{
		list.addListSelectionListener(ls);
	}
	

	
	//*********************************************************************************
	
	
}
